import { Navigator,  Platform, StatusBar, StyleSheet} from "react-native";
import Dimensions from 'Dimensions';
const {width: screenWidth, height: screenHeight} = Dimensions.get('window');
export const OS_IOS = 'ios';
export const OS_ANDROID = 'android';
let designScreenWidth = 750;
let designScreenHeight = 1334;
const pi = Dimensions.scale;
const fontScale = Dimensions.scale;
const statusBarHeight = Platform.OS === OS_IOS ? Navigator.NavigationBar.Styles.General.StatusBarHeight : StatusBar.currentHeight;
const openTranslucent = Platform.OS === OS_IOS || (Platform.OS === OS_ANDROID && Platform.Version >= 21);

const setDesignScreenSize = (width, height) => {
    designScreenWidth = width;
    designScreenHeight = height;
};

const getActualFontSize = function (designFontSize) {
    return designFontSize * screenHeight / designScreenHeight;
}

const getActualSizeInHorizontal = function (designWidth) {
    return designWidth * screenWidth / designScreenWidth;
};
const getActualSizeInVertical = function (designHeight) {
    return designHeight * screenHeight / designScreenHeight;
};

const navBarHeight = getActualSizeInVertical(88);

let navTotalHeight = navBarHeight + (openTranslucent ? statusBarHeight : 0);

const footerHeight = getActualSizeInVertical(120);

const baseStyle = StyleSheet.create(
    {
        // Text基本格式
        baseText: {
            backgroundColor: 'rgba(0, 0, 0, 0)', // 在iOS上，缺少这个属性有时候会有显示问题
            includeFontPadding: false, // 在Android上，缺少这个属性，会导致文字的位置有问题
            paddingLeft: 0,
            paddingRight: 0,
            paddingTop: 0,
            paddingBottom: 0,//取消默认的padding值
            textAlignVertical: 'center',
        },
        separator: {
            height: 1,
            backgroundColor: '#ede9dd',
        },
        contentViewStyle: {
            // 主轴方向
            flexDirection: 'row',
            // 换行
            flexWrap: 'wrap'
        },
        modalContainer: {
            position: "absolute",
            top: 0,
            left: 0,
            width:screenWidth,
            height:screenHeight,
            backgroundColor: "rgba(0,0,0,0.4)",
            justifyContent: "center",
            alignItems: "center",
        },
    }
);

baseStyle.screenWidth = screenWidth;
baseStyle.screenHeight = screenHeight;
baseStyle.statusBarHeight = statusBarHeight;
baseStyle.navBarHeight = navBarHeight;
baseStyle.navTotalHeight = navTotalHeight;
baseStyle.navBasePaddingTop = openTranslucent ? statusBarHeight : 0;
baseStyle.footerHeight = footerHeight;
baseStyle.getActualSizeInHorizontal = getActualSizeInHorizontal;
baseStyle.getActualSizeInVertical = getActualSizeInVertical;
baseStyle.getActualFontSize = getActualFontSize;
baseStyle.pi = pi;
baseStyle.openTranslucent = openTranslucent;

export default baseStyle;
